<?php
$isReloadable = false;
$isPopUp = true;
require_once("../../../pers/inc.config.php");
require_once('../../_inc/inc.session.php');
require_once('../../_inc/funct.html.php');
require_once('../../_inc/funct.tabDati.php');

$aExp = array();
$aExp['head']['data_ora'] = time();
$aExp['head']['server'] = $_SERVER['HTTP_HOST'];
$aExp['head']['data_base'] = RGL_DB_NAME.'@'.RGL_DB_HOST;
$aExp['head']['tipo'] = 'parind';

$sql_sel = "SELECT p.*, m.cod_mod_rbil " 
		." FROM rgl_mod_rbil m " 
		." LEFT JOIN rgl_mod_rbil_par_ind p ON p.id_mod_rbil = m.id_mod_rbil "
		." WHERE m.id_mod_rbil = ".reqVarInt('id')
		." ORDER BY p.cod_dato "
		;
$objDB->query($sql_sel,'selRecX');
if(!$acX = $objDB->fetch('selRecX')) { 
	die('id errato '.reqVar('id'));
}
$codModRbil = $acX['cod_mod_rbil'];
$aExp['head']['cod'] = $codModRbil;

while($acX) { 
	unset($acX['cod_mod_rbil']);
	$aExp['body']['parind'][] = $acX;
	$acX = $objDB->fetch('selRecX');
}
	
$sExpC = gzcompress(serialize($aExp));

headerDownLoad(strlen($sExpC),"parind_".$codModRbil."_".date('ymdHis').".ser");
echo $sExpC;
exit();
